package com.zemb.flxwear.UI.Activity;


import android.content.Intent;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zemb.flxwear.Adapter.CategoryAdapter;
import com.zemb.flxwear.Bean.CategoryBean;
import com.zemb.flxwear.R;
import com.zemb.flxwear.Utils.DeviceUtils;

import com.zemb.flxwear.Utils.VoicePlayUtils;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    RecyclerView recyclerView;
    List<CategoryBean> list;
    CategoryAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        initView();

    }

    public void initData() {
        adapter = new CategoryAdapter(this);
        list = new ArrayList<>();
        list.add(new CategoryBean(R.mipmap.home_all_icon, getResources().getString(R.string.home_btn_all_test), DeviceUtils.UIType.ALL));
        list.add(new CategoryBean(R.mipmap.home_single_icon, getResources().getString(R.string.home_btn_model_test), DeviceUtils.UIType.MODEL));
        list.add(new CategoryBean(R.mipmap.static_blood_pressure_green, getResources().getString(R.string.report), DeviceUtils.UIType.REPORT));
        list.add(new CategoryBean(R.mipmap.qr_green, getResources().getString(R.string.qr_code), DeviceUtils.UIType.QR_CODE));

    }

    public void initView() {
        recyclerView = findViewById(R.id.rc_category);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        adapter.setList(list);
        adapter.setOnItemClickListener((v, categoryBean, position) -> {
            Intent intent = null;
            switch (categoryBean.uiType) {
                case ALL:
                    intent = new Intent(MainActivity.this, MeasureActivity.class);
                    intent.putExtra("tag", DeviceUtils.Category.ALL);
                    break;
                case MODEL:
                    intent = new Intent(MainActivity.this, CategoryMeasureActivity.class);
                    break;
                case REPORT:
                    intent = new Intent(MainActivity.this, MedicalReportActivity.class);
                    break;
                case QR_CODE:
                    intent = new Intent(MainActivity.this, QrActivity.class);
                    break;
            }
            startActivity(intent);
        });
        recyclerView.setAdapter(adapter);
        VoicePlayUtils.getInstance().onCreate(this);
        VoicePlayUtils.getInstance().PlayWelcome();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}